#ifndef PageReplacementManager_h
#define PageReplacementManager_h

#include <map>
#include <list>
#include "resource.h"
#include "Memory.h"
#include "MemoryManagementUnit.h"

#define FIFO 1
#define WSClock 0

using std::map;
using std::list;

class PageReplacementManager
{
public:
	PageReplacementManager(int pSize, int kPages, int uPages, Memory* MM, Memory* disk, const int uAlgo, const int kAlgo, const int numOfEntries, MemoryManagementUnit* mmu,PCBS* processes, int clock);
	~PageReplacementManager(void);

	int loadUserPage(int processID, int pageNumber);
	int loadKernelPage(int processID, int pageNumber);

	void removeFIFO(int place, int mmIndex);

private:
	int FIFOReplace(int place);
	int WSClockReplace(int place);
	void updateMap(int pageNumber, PCB* requested, int data);

	PCBS* m_processes;
	Memory* m_MM;
	Memory* m_disk;
	MemoryManagementUnit* m_mmu;
	int** m_Map;
	int m_UserAlgo;
	int m_KernelAlgo;
	int m_NumOfEntries;	
	int m_numOfKernelPagesInMM;
	int m_numOfUserPagesInMM;
	int WSClockDelta;
	int m_PageSize;

	void writeToDisk(int place, int mmIndex);

	list<int>** fifo;

	int* clockHands;
};

#endif
